import pymysql

conn = pymysql.connect(host='127.0.0.1', user='root', passwd='passw0rd', db='csx_citegraph', port=3306)
cur = conn.cursor()
create_tmp_table = """create table tmp_target ( id BIGINT )"""
cur.execute(create_tmp_table)
conn.commit()
filenames = ['idlist1.txt', 'idlist2.txt', 'idlist3.txt', 'idlist4.txt', 'idlist5.txt', 'idlist6.txt']
idset = dict()
for fname in filenames:
    f = open(fname)
    lines = f.readlines()
    f.close()
    for line in lines:
        idset[int(line)] = True
idset = list(idset)
print(idset)
count = 0
for singleId in idset:
    count += 1
    cur.execute("insert into tmp_target values (%s)" % str(singleId))
    if count % 10 == 0:
        conn.commit()
cur.execute("create index id_index on tmp_target(id)")
conn.commit()
# done